package org.sample.springboot.validator.constraints.optional.fieldname;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import org.sample.springboot.validator.FieldNameOptionalValidator;

/**
 * Validate optional field when and only when enable field is enableFieldValue.
 *
 */
@Target({ TYPE, FIELD })
@Retention(RUNTIME)
@Constraint(validatedBy = FieldNameOptionalValidator.class)
@Repeatable(FieldNameOptionalConstraints.class)
@Documented
public @interface FieldNameOptionalConstraint {

	/**
	 * Name of the field that enables validate optional field.
	 */
	String enableFieldName();

	/**
	 * Value of enableField that enable validate optional field.
	 */
	boolean enableValue();

	/**
	 * Indicates enable validate when enableField is null.
	 */
	boolean enableForNull();

	/**
	 * Name of the field to be validated.
	 */
	String optionalFieldName();

	String message() default "";

	Class<?>[] groups() default {};

	Class<? extends Payload>[] payload() default {};

}
